﻿namespace EyeOpen.Math.Combinatorics
{
	using System.Collections;
	using System.Collections.Generic;

	public class CombinationEnumerator<T> : IEnumerator<T[]>
	{
		private readonly Combination<T> comb;
		private long current;

		internal CombinationEnumerator(int n, T[] items)
		{
			Reset();
			comb = new Combination<T>(n, items);
		}

		public T[] Current
		{
			get
			{
				return comb.GetCombination(current);
			}
		}

		object IEnumerator.Current
		{
			get { return Current; }
		}

		public bool MoveNext()
		{
			current++;
			return current < comb.Count;
		}

		public void Reset()
		{
			current = -1;
		}

		public void Dispose()
		{
		}
	}
}